using MediatR;
using WeatherSystem.API.Models;
using WeatherSystem.API.CQRS.Commands;

namespace WeatherSystem.API.CQRS.MediatR
{
    /// <summary>
    /// MediatR weather data requests
    /// </summary>
    public record GetWeatherDataPagedRequest(
        int Page = 1,
        int PageSize = 20,
        Guid? CityId = null,
        DateTime? StartDate = null,
        DateTime? EndDate = null,
        string? Source = null,
        string? SortBy = null,
        string? SortDirection = null
    ) : IRequest<PagedResult<Dictionary<string, object>>>;

    public record GetLatestWeatherRequest(Guid CityId) : IRequest<WeatherDataEntry?>;

    public record GetWeatherHistoryRequest(
        Guid CityId,
        DateTime StartDate,
        DateTime EndDate
    ) : IRequest<List<WeatherDataEntry>>;

    public record CollectWeatherDataRequest(Guid CityId) : IRequest<WeatherDataEntry>;

    public record CreateWeatherDataBatchRequest(
        List<CreateDynamicWeatherDataRequest> Requests
    ) : IRequest<List<Guid>>;

    public record UpdateWeatherDataRequest(
        Guid Id,
        UpdateDynamicWeatherDataRequest UpdateRequest
    ) : IRequest<bool>;

    public record DeleteWeatherDataRequest(Guid Id) : IRequest<bool>;

    public record GetWeatherStatsRequest() : IRequest<object>;

    public record SimulateWeatherDataRequest(
        decimal BaseTemperature = 20,
        int Count = 3
    ) : IRequest<SimulateWeatherDataResult>;

    /// <summary>
    /// City management requests
    /// </summary>
    public record GetCitiesRequest(
        int Page = 1,
        int PageSize = 50,
        bool? IsActive = null
    ) : IRequest<PagedResult<City>>;

    public record GetCityByIdRequest(Guid Id) : IRequest<City?>;

    /// <summary>
    /// Statistics requests
    /// </summary>
    public record GetStatisticsRangeRequest(
        Guid CityId,
        string? StatisticType = null,
        DateTime? StartDate = null,
        DateTime? EndDate = null
    ) : IRequest<List<Dictionary<string, object>>>;

    public record GenerateDailyStatisticsRequest(DateTime Date) : IRequest<bool>;

    /// <summary>
    /// User management requests
    /// </summary>
    public record GetUsersPagedRequest(
        int Page = 1,
        int PageSize = 20,
        bool? IsActive = null,
        UserRole? Role = null
    ) : IRequest<PagedResult<User>>;

    public record GetUserByIdRequest(Guid Id) : IRequest<User?>;
}